package com.tf.integrated.controller;

import com.alibaba.fastjson.JSONObject;
import com.ccssoft.m8.common.ccssoft.modules.util.EntityWrapperHandle;
import com.ccssoft.m8.common.web.BaseController;
import com.tf.integrated.entity.*;
import com.tf.integrated.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 查询预警信息
 * @author allen
 * @date: 2020年9月14日上午10:56:20
 */
@Api(value = "查询预警信息",description="SearchWarningInfoController")
@RestController
public class SearchWarningInfoController extends BaseController
{
    @Autowired
    private WarningresultbikepicwarndbtService<WarningresultbikepicwarndbtEntity> bikepicwarndbtService;

    @Autowired
    private WarningresultbikestrwarningstService<WarningresultbikestrwarningstEntity> bikestrwarningstService;

    @Autowired
    private WarningresultfacelibInfodbtService<WarningresultfacelibInfodbtEntity> facelibInfodbtService;

    @Autowired
    private WarningresultfacepicwarndbtService<WarningresultfacepicwarndbtEntity> facepicwarndbtService;

    @Autowired
    private WarningresultpedpicwarndbtService<WarningresultpedpicwarndbtEntity> pedpicwarndbtService;

    @Autowired
    private WarningresultpedstrwarningstService<WarningresultpedstrwarningstEntity> pedstrwarningstService;

    @Autowired
    private WarningresulttripicwarndbtService<WarningresulttripicwarndbtEntity> tripicwarndbtService;

    @Autowired
    private WarningresultvehlicwarndbtService<WarningresultvehlicwarndbtEntity> vehlicwarndbtService;

    @Autowired
    private WarningresultvehpicwarndbtService<WarningresultvehpicwarndbtEntity> vehpicwarndbtService;

    @Autowired
    private WarningresultvehstrwarningstService<WarningresultvehstrwarningstEntity> vehstrwarningstService;

    @Autowired
    private WarningresultfacestrinfodbtService<WarningresultfacestrinfodbtEntity> facestrinfodbtService;

    @ApiOperation("查询预警信息")
    @GetMapping("/search/warning/info")
    @CrossOrigin(origins = "*",maxAge = 86400)
    public SearchDataReturnEntity<List<JSONObject>> searchDataList(@RequestParam Map<String, Object> data) {
        if (data != null && data.size() > 0) {
            String starttime = (String) data.get("starttime");
            String endtime = (String) data.get("endtime");
            String spage=(String)data.get("page");
            String ssize=(String)data.get("size");
            int page=0;
            int size=0;
            if(isExist(spage)&&isInteger(spage)){
                page=Integer.parseInt(spage);
            }
            if(isExist(ssize)&&isInteger(ssize)){
                size=Integer.parseInt(ssize);
            }
            int total=0;
            List<JSONObject> all=new ArrayList<>();
            if(page>=1&&size>0&&size<=200&&isExist(starttime)&&isExist(endtime)){
                String stype=(String) data.get("wtype");
                int wtype=0;
                if(isExist(stype)&&isInteger(stype)){
                    wtype=Integer.parseInt(stype);
                }
                String wname = (String) data.get("wname");
                String host = (String) data.get("host");
                String chn = (String) data.get("chnId");
                if(wtype>0){
                    addList(wtype,starttime,endtime,wname,host,chn,all);
                }else{
                    int[] types= new int[]{1,2,3,4,5,6,7,8,9,10,11};
                    for(int type:types){
                        addList(type,starttime,endtime,wname,host,chn,all);
                    }
                }
                total=all.size();
                all.sort((a1,a2)-> a2.getDate("createtime").compareTo(a1.getDate("createtime")));
                int begin = (page - 1) * size;
                int end = begin + size;
                if(begin>=all.size()){
                    all.clear();
                }else{
                    all= all.subList(begin,Math.min(end,all.size()));
                }
            }
            return  new SearchDataReturnEntity<List<JSONObject>>().ok(all,200,total);
        }
        return new SearchDataReturnEntity<List<JSONObject>>().error("page or size error");
    }

    public void addList(int type,String starttime,String endtime,String wname,String host,String chn,List<JSONObject> all){
        switch (type){
            case 1:{
                all.addAll(getListType1(starttime,endtime,wname,host,chn));
                break;
            }
            case 2:{
                all.addAll(getListType2(starttime,endtime,wname,host,chn));
                break;
            }
            case 3:{
                all.addAll(getListType3(starttime,endtime,wname,host,chn));
                break;
            }
            case 4:{
                all.addAll(getListType4(starttime,endtime,wname,host,chn));
                break;
            }
            case 5:{
                all.addAll(getListType5(starttime,endtime,wname,host,chn));
                break;
            }
            case 6:{
                all.addAll(getListType6(starttime,endtime,wname,host,chn));
                break;
            }
            case 7:{
                all.addAll(getListType7(starttime,endtime,wname,host,chn));
                break;
            }
            case 8:{
                all.addAll(getListType8(starttime,endtime,wname,host,chn));
                break;
            }
            case 9:{
                all.addAll(getListType9(starttime,endtime,wname,host,chn));
                break;
            }
            case 10:{
                all.addAll(getListType10(starttime,endtime,wname,host,chn));
                break;
            }
            case 11:{
                all.addAll(getListType11(starttime,endtime,wname,host,chn));
                break;
            }
        }
    }

    public ArrayList<JSONObject> getListType1(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultvehstrwarningstEntity> ew = new EntityWrapperHandle<WarningresultvehstrwarningstEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultvehstrwarningstEntity> list = vehstrwarningstService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultvehstrwarningstEntity warningresultvehstrwarningstEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultvehstrwarningstEntity.getId());
                json.put("Licence", warningresultvehstrwarningstEntity.getLicence());
                json.put("Id", warningresultvehstrwarningstEntity.getUid());
                json.put("Name", warningresultvehstrwarningstEntity.getName());
                json.put("Reason", warningresultvehstrwarningstEntity.getReason());
                json.put("Time", warningresultvehstrwarningstEntity.getTime());
                json.put("VehStrDesc", warningresultvehstrwarningstEntity.getVehstrdesc());
                json.put("DeviceId",warningresultvehstrwarningstEntity.getDeviceid());
                json.put("Chn",warningresultvehstrwarningstEntity.getChn());
                json.put("FullPicPath",warningresultvehstrwarningstEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultvehstrwarningstEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultvehstrwarningstEntity.getWarningpicpath());
                se.put("resultType", 1);
                se.put("info", json);
                se.put("createtime", warningresultvehstrwarningstEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType2(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultvehpicwarndbtEntity> ew = new EntityWrapperHandle<WarningresultvehpicwarndbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultvehpicwarndbtEntity> list = vehpicwarndbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultvehpicwarndbtEntity warningresultvehpicwarndbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultvehpicwarndbtEntity.getId());
                json.put("Desc", warningresultvehpicwarndbtEntity.getDesc());
                json.put("Id", warningresultvehpicwarndbtEntity.getUid());
                json.put("Name", warningresultvehpicwarndbtEntity.getName());
                json.put("Reason", warningresultvehpicwarndbtEntity.getReason());
                json.put("Similarity", warningresultvehpicwarndbtEntity.getSimilarity());
                json.put("Sumsquares", warningresultvehpicwarndbtEntity.getSumsquares());
                json.put("Threshold", warningresultvehpicwarndbtEntity.getThreshold());
                json.put("Time", warningresultvehpicwarndbtEntity.getTime());
                json.put("DeviceId",warningresultvehpicwarndbtEntity.getDeviceid());
                json.put("Chn",warningresultvehpicwarndbtEntity.getChn());
                json.put("FullPicPath",warningresultvehpicwarndbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultvehpicwarndbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultvehpicwarndbtEntity.getWarningpicpath());
                se.put("resultType", 2);
                se.put("info", json);
                se.put("createtime", warningresultvehpicwarndbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType3(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultvehlicwarndbtEntity> ew = new EntityWrapperHandle<WarningresultvehlicwarndbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultvehlicwarndbtEntity> list = vehlicwarndbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultvehlicwarndbtEntity warningresultvehlicwarndbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultvehlicwarndbtEntity.getId());
                json.put("Licence", warningresultvehlicwarndbtEntity.getLicence());
                json.put("Id", warningresultvehlicwarndbtEntity.getUid());
                json.put("Name", warningresultvehlicwarndbtEntity.getName());
                json.put("Reason", warningresultvehlicwarndbtEntity.getReason());
                json.put("Time", warningresultvehlicwarndbtEntity.getTime());
                json.put("DeviceId",warningresultvehlicwarndbtEntity.getDeviceid());
                json.put("Chn",warningresultvehlicwarndbtEntity.getChn());
                json.put("FullPicPath",warningresultvehlicwarndbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultvehlicwarndbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultvehlicwarndbtEntity.getWarningpicpath());
                se.put("resultType", 3);
                se.put("info", json);
                se.put("createtime", warningresultvehlicwarndbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType4(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresulttripicwarndbtEntity> ew = new EntityWrapperHandle<WarningresulttripicwarndbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresulttripicwarndbtEntity> list = tripicwarndbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresulttripicwarndbtEntity warningresulttripicwarndbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresulttripicwarndbtEntity.getId());
                json.put("Desc", warningresulttripicwarndbtEntity.getDesc());
                json.put("Id", warningresulttripicwarndbtEntity.getUid());
                json.put("Name", warningresulttripicwarndbtEntity.getName());
                json.put("Reason", warningresulttripicwarndbtEntity.getReason());
                json.put("Similarity", warningresulttripicwarndbtEntity.getSimilarity());
                json.put("Sumsquares", warningresulttripicwarndbtEntity.getSumsquares());
                json.put("Threshold", warningresulttripicwarndbtEntity.getThreshold());
                json.put("Time", warningresulttripicwarndbtEntity.getTime());
                json.put("DeviceId",warningresulttripicwarndbtEntity.getDeviceid());
                json.put("Chn",warningresulttripicwarndbtEntity.getChn());
                json.put("FullPicPath",warningresulttripicwarndbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresulttripicwarndbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresulttripicwarndbtEntity.getWarningpicpath());
                se.put("resultType", 4);
                se.put("info", json);
                se.put("createtime", warningresulttripicwarndbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType5(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultpedstrwarningstEntity> ew = new EntityWrapperHandle<WarningresultpedstrwarningstEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultpedstrwarningstEntity> list = pedstrwarningstService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultpedstrwarningstEntity warningresultpedstrwarningstEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultpedstrwarningstEntity.getId());
                json.put("Id", warningresultpedstrwarningstEntity.getUid());
                json.put("Name", warningresultpedstrwarningstEntity.getName());
                json.put("PedStrDesc", warningresultpedstrwarningstEntity.getPedstrdesc());
                json.put("Reason", warningresultpedstrwarningstEntity.getReason());
                json.put("Time", warningresultpedstrwarningstEntity.getTime());
                json.put("DeviceId",warningresultpedstrwarningstEntity.getDeviceid());
                json.put("Chn",warningresultpedstrwarningstEntity.getChn());
                json.put("FullPicPath",warningresultpedstrwarningstEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultpedstrwarningstEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultpedstrwarningstEntity.getWarningpicpath());
                se.put("resultType", 5);
                se.put("info", json);
                se.put("createtime", warningresultpedstrwarningstEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType6(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultpedpicwarndbtEntity> ew = new EntityWrapperHandle<WarningresultpedpicwarndbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultpedpicwarndbtEntity> list = pedpicwarndbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultpedpicwarndbtEntity warningresultpedpicwarndbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultpedpicwarndbtEntity.getId());
                json.put("Desc", warningresultpedpicwarndbtEntity.getDesc());
                json.put("Id", warningresultpedpicwarndbtEntity.getUid());
                json.put("Name", warningresultpedpicwarndbtEntity.getName());
                json.put("Reason", warningresultpedpicwarndbtEntity.getReason());
                json.put("Similarity", warningresultpedpicwarndbtEntity.getSimilarity());
                json.put("Sumsquares", warningresultpedpicwarndbtEntity.getSumsquares());
                json.put("Threshold", warningresultpedpicwarndbtEntity.getThreshold());
                json.put("Time", warningresultpedpicwarndbtEntity.getTime());
                json.put("DeviceId",warningresultpedpicwarndbtEntity.getDeviceid());
                json.put("Chn",warningresultpedpicwarndbtEntity.getChn());
                json.put("FullPicPath",warningresultpedpicwarndbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultpedpicwarndbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultpedpicwarndbtEntity.getWarningpicpath());
                se.put("resultType", 6);
                se.put("info", json);
                se.put("createtime", warningresultpedpicwarndbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType7(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultbikestrwarningstEntity> ew = new EntityWrapperHandle<WarningresultbikestrwarningstEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultbikestrwarningstEntity> list = bikestrwarningstService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultbikestrwarningstEntity warningresultbikestrwarningstEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultbikestrwarningstEntity.getId());
                json.put("BikeStrDesc", warningresultbikestrwarningstEntity.getBikestrdesc());
                json.put("Id", warningresultbikestrwarningstEntity.getUid());
                json.put("Name", warningresultbikestrwarningstEntity.getName());
                json.put("Reason", warningresultbikestrwarningstEntity.getReason());
                json.put("Time", warningresultbikestrwarningstEntity.getTime());
                json.put("DeviceId",warningresultbikestrwarningstEntity.getDeviceid());
                json.put("Chn",warningresultbikestrwarningstEntity.getChn());
                json.put("FullPicPath",warningresultbikestrwarningstEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultbikestrwarningstEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultbikestrwarningstEntity.getWarningpicpath());
                se.put("resultType", 7);
                se.put("info", json);
                se.put("createtime", warningresultbikestrwarningstEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType8(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultbikepicwarndbtEntity> ew = new EntityWrapperHandle<WarningresultbikepicwarndbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultbikepicwarndbtEntity> list = bikepicwarndbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultbikepicwarndbtEntity warningresultbikepicwarndbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultbikepicwarndbtEntity.getId());
                json.put("Desc", warningresultbikepicwarndbtEntity.getDesc());
                json.put("Id", warningresultbikepicwarndbtEntity.getUid());
                json.put("Name", warningresultbikepicwarndbtEntity.getName());
                json.put("Reason", warningresultbikepicwarndbtEntity.getReason());
                json.put("Similarity", warningresultbikepicwarndbtEntity.getSimilarity());
                json.put("Sumsquares", warningresultbikepicwarndbtEntity.getSumsquares());
                json.put("Threshold", warningresultbikepicwarndbtEntity.getThreshold());
                json.put("Time", warningresultbikepicwarndbtEntity.getTime());
                json.put("DeviceId",warningresultbikepicwarndbtEntity.getDeviceid());
                json.put("Chn",warningresultbikepicwarndbtEntity.getChn());
                json.put("FullPicPath",warningresultbikepicwarndbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultbikepicwarndbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultbikepicwarndbtEntity.getWarningpicpath());
                se.put("resultType", 8);
                se.put("info", json);
                se.put("createtime", warningresultbikepicwarndbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType9(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultfacepicwarndbtEntity> ew = new EntityWrapperHandle<WarningresultfacepicwarndbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultfacepicwarndbtEntity> list = facepicwarndbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultfacepicwarndbtEntity warningresultfacepicwarndbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultfacepicwarndbtEntity.getId());
                json.put("Address", warningresultfacepicwarndbtEntity.getAddress());
                json.put("Birthday", warningresultfacepicwarndbtEntity.getBirthday());
                json.put("IDNumber", warningresultfacepicwarndbtEntity.getIdnumber());
                json.put("Id", warningresultfacepicwarndbtEntity.getUid());
                json.put("LibId", warningresultfacepicwarndbtEntity.getLibid());
                json.put("Name", warningresultfacepicwarndbtEntity.getName());
                json.put("Sex", warningresultfacepicwarndbtEntity.getSex());
                json.put("Similarity", warningresultfacepicwarndbtEntity.getSimilarity());
                json.put("Sumsquares", warningresultfacepicwarndbtEntity.getSumsquares());
                json.put("Threshold", warningresultfacepicwarndbtEntity.getThreshold());
                json.put("Time", warningresultfacepicwarndbtEntity.getTime());
                json.put("DeviceId",warningresultfacepicwarndbtEntity.getDeviceid());
                json.put("Chn",warningresultfacepicwarndbtEntity.getChn());
                json.put("FullPicPath",warningresultfacepicwarndbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultfacepicwarndbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultfacepicwarndbtEntity.getWarningpicpath());
                se.put("resultType", 9);
                se.put("info", json);
                se.put("createtime", warningresultfacepicwarndbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType10(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultfacelibInfodbtEntity> ew = new EntityWrapperHandle<WarningresultfacelibInfodbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultfacelibInfodbtEntity> list = facelibInfodbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultfacelibInfodbtEntity warningresultfacelibInfodbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultfacelibInfodbtEntity.getId());
                json.put("Enable", warningresultfacelibInfodbtEntity.getEnable());
                json.put("Id", warningresultfacelibInfodbtEntity.getUid());
                json.put("Name", warningresultfacelibInfodbtEntity.getName());
                json.put("Reason", warningresultfacelibInfodbtEntity.getReason());
                json.put("StrangerMode", warningresultfacelibInfodbtEntity.getStrangermode());
                json.put("Time", warningresultfacelibInfodbtEntity.getTime());
                json.put("TotalMem", warningresultfacelibInfodbtEntity.getTotalmem());
                json.put("DeviceId",warningresultfacelibInfodbtEntity.getDeviceid());
                json.put("Chn",warningresultfacelibInfodbtEntity.getChn());
                json.put("FullPicPath",warningresultfacelibInfodbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultfacelibInfodbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultfacelibInfodbtEntity.getWarningpicpath());
                se.put("resultType", 10);
                se.put("info", json);
                se.put("createtime", warningresultfacelibInfodbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public ArrayList<JSONObject> getListType11(String starttime,String endtime,String wname,String host,String chn){
        EntityWrapperHandle<WarningresultfacestrinfodbtEntity> ew = new EntityWrapperHandle<WarningresultfacestrinfodbtEntity>();
        ew.between("createtime",starttime,endtime);
        if(isExist(wname)){
            ew.like("name",wname);
        }
        if(isExist(host)){
            ew.eq("deviceid",host);
        }
        if(isExist(chn)){
            ew.eq("chn",chn);
        }
        List<WarningresultfacestrinfodbtEntity> list = facestrinfodbtService.selectList(ew);
        ArrayList<JSONObject> arr=new ArrayList<>();
        if(list!=null&&list.size()>0) {
            for (WarningresultfacestrinfodbtEntity warningresultfacestrinfodbtEntity : list) {
                JSONObject se = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id", warningresultfacestrinfodbtEntity.getId());
                json.put("Id", warningresultfacestrinfodbtEntity.getUid());
                json.put("Name", warningresultfacestrinfodbtEntity.getName());
                json.put("FaceStrDesc", warningresultfacestrinfodbtEntity.getFacestrdesc());
                json.put("Reason", warningresultfacestrinfodbtEntity.getReason());
                json.put("Time", warningresultfacestrinfodbtEntity.getTime());
                json.put("DeviceId",warningresultfacestrinfodbtEntity.getDeviceid());
                json.put("Chn",warningresultfacestrinfodbtEntity.getChn());
                json.put("FullPicPath",warningresultfacestrinfodbtEntity.getFullpicpath());
                json.put("ObjPicPath",warningresultfacestrinfodbtEntity.getObjpicpath());
                json.put("WarningPicPath",warningresultfacestrinfodbtEntity.getWarningpicpath());
                se.put("resultType", 11);
                se.put("info", json);
                se.put("createtime", warningresultfacestrinfodbtEntity.getCreatetime());
                arr.add(se);
            }
        }
        return arr;
    }

    public boolean isExist(String value){
        return value != null && !value.equals("") ;
    }

    public boolean isInteger(String str) {
        Pattern pattern = Pattern.compile("^[-+]?[\\d]*$");
        return pattern.matcher(str).matches();
    }
}